package com.java.demo;

import com.java.demo.Model.User;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.annotation.Autowired;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

public class BeanLifeComponent implements BeanNameAware {
    @Autowired
    private User user;

    @Override
    public void setBeanName(String s) {
        System.out.println("执行了 BeanNameAware -> " + s);
    }

    @PostConstruct
    public void doPostConstruct(){
        System.out.println("执行了 @PostConstruct");
        System.out.println(user.toString());
    }

    public void myInit(){
        System.out.println("执行了 myInit");
    }

    @PreDestroy
    public void doPreDestroy(){
        System.out.println("执行了 @PreDestroy");
    }

    public void sayHi(){
        System.out.println("使用了 Bean");
    }
}
